package config

import (
	"github.com/spf13/viper"
	"log"
)

type Config struct {
	Mysql
	Redis
	HYWXSendSms
}

type Mysql struct {
	Host     string
	Pose     int
	User     string
	Password string
	DB       string
}

type Redis struct {
	Addr     string
	Password string
	DB       int
}

type HYWXSendSms struct {
	ID  string
	KEY string
}

var Conf Config

func Init() {
	viper.SetConfigFile("./config/config.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		log.Println("解析失败", err)
		return
	}
	err = viper.Unmarshal(&Conf)
	if err != nil {
		log.Println("配置失败", err)
		return
	}
}
